package com.jiangnan.artstudio.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.jiangnan.artstudio.R;
import com.jiangnan.artstudio.adapter.XiaoxiAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CyglXiaoXi extends BaseFragment {

    private ListView listView;
    private List<Map<String,Object>> dataList;
    private int[] iconHead={R.drawable.head10,R.drawable.head11};
    private String[] Name={"Oliver Sister","Girlsareawe"};
    private String[] schools={"艺术设计152","艺术设计152"};
    private String[] permits={"同意","不同意"};
    private String[] goMessage = {"用自己的插画陆续做一些丝巾设计……","画册设计"};
    private List<int[]> list = new ArrayList<int[]>();

    private XiaoxiAdapter adapter;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.cygl_xiaoxi,container,false);

        findViewId(view);

        int[] imgs1 = {R.drawable.xiaoxi_img_1,R.drawable.xiaoxi_img_2,R.drawable.xiaoxi_img_3,R.drawable.xiaoxi_img_4};
        int[] imgs2 = {R.drawable.xiaoxi_img_5,R.drawable.xiaoxi_img_6,R.drawable.xiaoxi_img_7,R.drawable.xiaoxi_img_8};
        list.add(imgs1);
        list.add(imgs2);

        dataList=new ArrayList<>();
        adapter = new XiaoxiAdapter(getContext(),getData());
        listView.setAdapter(adapter);
        hideScroll(listView);
        return view;
    }
    public List<Map<String,Object>> getData(){
        for(int i=0;i<iconHead.length;i++){
            Map<String,Object>map=new HashMap<>();
            map.put("head",iconHead[i]);
            map.put("name",Name[i]);
            map.put("school",schools[i]);
            map.put("permit",permits[i]);
            map.put("message",goMessage[i]);
            map.put("imgList",list.get(i));
            dataList.add(map);
        }
        return dataList;
    }
    public void findViewId(View view) {
        listView = view.findViewById(R.id.xiaoxi_list);
    }

}
